/*
 * $Id: ObjectModel.java 136 2009-07-16 07:53:43Z donbeave $
 */

package labour.concept.client.data;

import java.util.Date;

@SuppressWarnings("serial")
public class ObjectModel extends IdModel {

  public ObjectModel() {
    set(CHILDREN_COUNT, 0);
    set(SORT_ORDER, 0);
    set(PARENT_ID, "0");
  }

  public static final String TYPE_ID = "TypeID";
  public static final String PARENT_ID = "ParentID";
  public static final String SORT_ORDER = "SortOrder";
  public static final String DATE_UPDATE = "DateUpdate";
  public static final String CHILDREN_COUNT = "childrenCount";

  public static final String PARENT_UID = "ParentUID";

  public String getId() {
    return get(ID);
  }

  public String getTypeId() {
    return get(TYPE_ID);
  }

  public String getParentId() {
    return get(PARENT_ID);
  }

  public String getParentUId() {
    return get(PARENT_UID);
  }

  public int getSortOrder() {
    return (Integer) get(SORT_ORDER);
  }

  public void setSortOrder(int order) {
    set(SORT_ORDER, order);
  }

  public Date getDateUpdate() {
    return get(DATE_UPDATE);
  }

  public int getChildrenCount() {
    return (Integer) get(CHILDREN_COUNT);
  }

  public Boolean isExist() {
    if (getId() != null && !getId().equals("0")) {
      return true;
    }
    return false;
  }

  public Boolean isRoot() {
    if (getParentId() == null || getParentId().equals("0")) {
      return true;
    }
    return false;
  }

}
